package com.pmcc.core.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by syk on 17/6/21.
 */
@Configuration
public class MyWebAppConfig extends WebMvcConfigurerAdapter {

    @Value("${web.downloadFile}")
    private String downloadFile;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/*/**.**.js").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/downloadFile/**").addResourceLocations("file:"+downloadFile);
        super.addResourceHandlers(registry);
    }
    /**
     * 重写configurePathMatch此方法	 * 设置其参数PathMatchConfigurer的属性UseSuffixPatternMatch值为false	 * 可以让路径中带小数点“.”后面的值不被忽略
     */
    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        configurer.setUseSuffixPatternMatch(false);
    }

}
